
using FS.Common.DotNetBean;
using FS.Common.DotNetCode;
using FS.Common.DotNetUI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.UI.WebControls;

namespace FS.Web.BLL.SysUser
{
    public partial class UserInfo_List : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!base.IsPostBack)
            {
                //Response.Write("");
            }
            this.PageControl1.pageHandler += new EventHandler(this.pager_PageChanged);
        }
        protected void pager_PageChanged(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
        private void DataBindGrid()
        {
            int count = 0;
            if (this.Hchange.Value == "1")
            {
                this.PageControl1.PageIndex = 1;
                this.Hchange.Value = "0";
            }
            StringBuilder SqlWhere = new StringBuilder();
            IList<SqlParam> IList_param = new List<SqlParam>();
            if (!string.IsNullOrEmpty(this.txt_Search.Value))
            {
                SqlWhere.Append(" and U." + this.Searchwhere.Value + " like @obj ");
                IList_param.Add(new SqlParam("@obj", '%' + this.txt_Search.Value.Trim() + '%'));
            }

            string ls_username = RequestSession.GetSessionUser().UserAccount.ToString().ToLower();
            if (ls_username != "system")
            {
                SqlWhere.Append(" and (U.User_Account <> 'system')");
            }

            DataTable dt = this._sys_idao.GetUserInfoPage(SqlWhere, IList_param, this.PageControl1.PageIndex, this.PageControl1.PageSize, ref count);
            ControlBindHelper.BindRepeaterList(dt, this.rp_Item);
            this.PageControl1.SetPageCount(count);
        }
        protected void rp_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Label lblDeleteMark = e.Item.FindControl("lblDeleteMark") as Label;
                if (lblDeleteMark != null)
                {
                    string textDeleteMark = lblDeleteMark.Text;
                    textDeleteMark = textDeleteMark.Replace("1", "<span style='color:Blue'>启用</span>");
                    textDeleteMark = textDeleteMark.Replace("2", "<span style='color:red'>停用</span>");
                    lblDeleteMark.Text = textDeleteMark;
                }
            }
        }
        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
    }
}
